﻿using System.Collections.Generic;

using UnityEngine;
using System;
using System.Collections;
/// 单件类
public class Singleton<T> where T : class
{
    /// 实例
    private static T instance;

    /// 实例
    public static T Instance
    {
        get
        {
            if (instance == null) {
                Type type = typeof(T);
                instance = (T)Activator.CreateInstance(type, true);
            }

            return instance;
        }
    }

    public bool IsValidate() {
        return instance != null;
    }

    protected void CleanUp()
    {
        instance = null;
    }

    public virtual void Init()
    {
        
    }

    
}


